<template>
  <div>
    <section>
      <div><span>总营业额：</span></div>
      <div><span>销量：</span></div>
      <div>
        <span>综合评分：</span>
      </div>
    </section>
    <div id="MySector"></div>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  name: "comRadar",
  data() {
    return {
      myChart: {},
    };
  },
  methods: {
    // 方法
    init() {
      this.myChart = echarts.init(document.getElementById("MySector"));
      window.addEventListener("resize", this.resize);
    },
    sizeChange() {
      this.myChart.resize();
    },
  },
  mounted() {
    this.init();
    let optionData = {
      title: {
        text: "商品销售额视图",
        subtext: "总额：1212",
        left: "center",
      },
      tooltip: {
        trigger: "item",
      },
      legend: {
        orient: "vertical",
        left: "left",
      },
      series: [
        {
          name: "销售数量",
          type: "pie",
          radius: "50%",
          data: [
            { value: 1048, name: "鞋类" },
            { value: 735, name: "上衣" },
            { value: 580, name: "下装" },
            { value: 484, name: "饰品" },
          ],
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: "rgba(0, 0, 0, 0.5)",
            },
          },
        },
      ],
    };
    this.myChart.setOption(optionData);
  },
  beforeDestroy() {
    // 移除监听
    window.removeEventListener("resize", this.resize);
  },
};
</script>

<style lang="scss" scoped>
section {
  display: flex;
  justify-content: space-around;
  text-align: center;
  margin: 30px auto;
  width: 1000px;
  font-size: 20px;
  color: white;
  > div {
    width: 300px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
    border-radius: 4px;
  }
  > div:first-child {
    background-color: red;
  }
  > div:nth-child(2) {
    background-color: blue;
  }
  > div:nth-child(3) {
    background-color: rgb(139, 139, 56);
  }
}
#MySector {
  width: 500px;
  height: 500px;
  margin: 0 auto;
}
</style>